package com.study.mr.mapjoin;


import com.study.mr.reducejoin.Orderpd;
import com.study.mr.reducejoin.ReduceJoinDriver;
import com.study.mr.reducejoin.ReduceJoinMapper;
import com.study.mr.reducejoin.ReduceJoinReducer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;
import java.net.URI;

public class MapJoinDriver {
    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf);
        job.setJarByClass(MapJoinDriver.class);
        job.setMapperClass(MapJoinMapper.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(NullWritable.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);

        //设置ReducerTask数量为0
        job.setNumReduceTasks(0);

        //设置缓冲文件路径
        job.addCacheFile(URI.create("file:///D:/hadoopbook/demodate/cachefile/pd.txt"));

        FileInputFormat.setInputPaths(job,new Path("D:\\hadoopbook\\demodate\\mapjoin"));
        FileOutputFormat.setOutputPath(job,new Path("D:\\hadoopbook\\demodate\\mapjoin_out2"));

        job.waitForCompletion(true);

    }
}
